package ltd.newbee.mall.listener;


import ltd.newbee.mall.common.R;
import ltd.newbee.mall.service.NewBeeMallOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;

/**
 * 贝宝支付回调
 * @author pyw
 */
@RestController
public class OrderPayedPaypalListener {

    @Autowired
    NewBeeMallOrderService orderService;

    @PostMapping("/payed/paypal/notify")
    public R handlePayPal(@RequestParam("token") String token, @RequestParam("PayerID")String PayerID) throws IOException {
        orderService.orderCaptureOrder(token);
        System.out.println("授权成功");
        return R.ok();
    }

}
